*************************************************************************
*																		*
*					Campaign Panel Book Table 1							*
*																		*
*************************************************************************	

/*
This do-file shows the empirical distribution of the respondents in four different representative surveys.
*/

***Cross-section 2009 Post-election study

use "${data}\CS2009.dta",clear

*Removal of  pre-election respondents
drop if survey1==1

*Age
tab vn542

gen alter=vn542
replace alter=-99 if vn542<18
mvdecode alter, mv (-99)
tab alter

sum alter 


*Education 
fre vn9a
gen bildkat=0
replace bildkat=1 if vn9a<=2
replace bildkat=2 if vn9a==3
replace bildkat=3 if vn9a==4 | vn9a==5
mvdecode bildkat, mv (0)
tab bildkat


*Political Interest
fre vn217
mvdecode vn217, mv (98/99)
gen polint=(5-vn217)/4
sum polint


*Election Norm
fre vn130e
mvdecode vn130e, mv (98/99)
gen wahlnorm=(vn130e-1)/4
tabstat wahlnorm, sta (n min max mean sd)


*Party Identification
fre vn135?

gen pid=0
replace pid=1 if vn135a>=2 & vn135a<=7
replace pid=. if vn135a==999
gen cdupid=0
replace cdupid=1 if vn135a==2 | vn135a==3
replace cdupid=. if vn135a==999
gen spdpid=0
replace spdpid=1 if vn135a==4
replace spdpid=. if vn135a==999
gen fdppid=0
replace fdppid=1 if vn135a==5
replace fdppid=. if vn135a==999
gen grupid=0
replace grupid=1 if vn135a==6
replace grupid=. if vn135a==999
gen linpid=0
replace linpid=1 if vn135a==7
replace linpid=. if vn135a==999
tabstat pid cdupid spdpid fdppid grupid linpid, sta (n min max mean sd)


*Voter Turnout
fre n111
gen wbt=1
replace wbt=-99 if n111==100
replace wbt=0 if n111>1 & n111<100
mvdecode wbt, mv (-99)
tab wbt


*Election Result
fre n169_2a
mvdecode n169_2a, mv (999/1002)
tab n169_2a


***Short-term panel 2009

use "${data}\STP2009.dta",clear

set more off

fre teilnahme
fre w?


*Determine Sample for Panel
gen panel = .
replace panel=1 if w1==1 & w7==1
replace panel=1 if w2==1 & w1==0 & w7==1

*Determine Sample for Panel Select 
gen panel_select = .
replace panel_select = 1 if teilnahme==7
replace panel_select = 1 if teilnahme==6 & w1==0



*Age
tab kpx_2290a

gen alter=kpx_2290a
replace alter=-99 if kpx_2290a<18
mvdecode alter, mv (-99)
tab alter

sum alter if panel==1
sum alter if panel_select==1


*Education 
fre kpx_2320
gen bildkat=0
replace bildkat=1 if kpx_2320<=2
replace bildkat=2 if kpx_2320==3
replace bildkat=3 if kpx_2320==4 | kpx_2320==5
mvdecode bildkat, mv (0)

tab bildkat if panel==1
tab bildkat if panel_select==1

*Political Interest
fre kp2_010
mvdecode kp2_010, mv (98/99)
gen polint=(5-kp2_010)/4

sum polint if panel==1
sum polint if panel_select==1

*Election Norm
fre kp?_050l
mvdecode kp1_050l kp4_050l, mv (98/99)
gen wahlnorm=kp1_050l
replace wahlnorm = kp4_050l if w2==1 & w1==0
replace wahlnorm=(wahlnorm-1)/4

tabstat wahlnorm if panel==1, sta (n min max mean sd)
tabstat wahlnorm if panel_select==1, sta (n min max mean sd)

*Party Identification
fre kp1_2090 kp3_2090

gen pid_ges = kp1_2090
replace pid_ges = kp3_2090 if w2==1 & w1==0

gen pid=0
replace pid=1 if pid_ges>=2 & pid_ges<=7
replace pid=. if pid_ges==999
gen cdupid=0
replace cdupid=1 if pid_ges==2 | pid_ges==3
replace cdupid=. if pid_ges==999
gen spdpid=0
replace spdpid=1 if pid_ges==4
replace spdpid=. if pid_ges==999
gen fdppid=0
replace fdppid=1 if pid_ges==5
replace fdppid=. if pid_ges==999
gen grupid=0
replace grupid=1 if pid_ges==6
replace grupid=. if pid_ges==999
gen linpid=0
replace linpid=1 if pid_ges==7
replace linpid=. if pid_ges==999

tabstat pid cdupid spdpid fdppid grupid linpid if panel==1, sta (n min max mean sd)
tabstat pid cdupid spdpid fdppid grupid linpid if panel_select==1, sta (n min max mean sd)

*Voter Turnout
fre kp7_180
gen wbt=1
replace wbt=-99 if kp7_180==100
replace wbt=0 if kp7_180>1 & kp7_180<100
mvdecode wbt, mv (-99)

tab wbt if panel==1
tab wbt if panel_select==1


*Election Result
fre kp7_200b
mvdecode kp7_200b, mv (999/1002)

tab kp7_200b if panel==1
tab kp7_200b if panel_select==1




***Cross-section 2013 Post-election study

use "${data}\CS2013.dta",clear

set more off

*Removal of  pre-election respondents
drop if survey==1

*Age
tab vn2c

gen alter=2013 - vn2c
replace alter=-99 if vn2c>1995
mvdecode alter, mv (-99)
tab alter

sum alter 


*Education 
fre vn163
mvdecode vn163, mv (-99)
gen bildkat=0
replace bildkat=1 if vn163<=2
replace bildkat=2 if vn163==3
replace bildkat=3 if vn163==4 | vn163==5
mvdecode bildkat, mv (0)
tab bildkat


*Political Interest
fre vn3
mvdecode vn3, mv (-99/-98)
gen polint=(5-vn3)/4
sum polint


*Election Norm
fre vn73d
mvdecode vn73d, mv (-99/-98)
gen wahlnorm=(vn73d-1)/4
tabstat wahlnorm, sta (n min max mean sd)


*Party Identification
fre vn119a

gen pid=0
replace pid=1 if vn119a>=2 & vn119a<=801
replace pid=. if vn119a==999
gen cdupid=0
replace cdupid=1 if vn119a==1 | vn119a==2 | vn119a==3
replace cdupid=. if vn119a==999
gen spdpid=0
replace spdpid=1 if vn119a==4
replace spdpid=. if vn119a==999
gen fdppid=0
replace fdppid=1 if vn119a==5
replace fdppid=. if vn119a==999
gen grupid=0
replace grupid=1 if vn119a==6
replace grupid=. if vn119a==999
gen linpid=0
replace linpid=1 if vn119a==7
replace linpid=. if vn119a==999
tabstat pid cdupid spdpid fdppid grupid linpid, sta (n min max mean sd)


*Voter Turnout
fre n10
gen wbt=1
replace wbt=-99 if n10==-97
replace wbt=0 if n10==-99 | n10==2
mvdecode wbt, mv (-99)
tab wbt


*Election Result
fre n11ba
mvdecode n11ba, mv (-99 -97/-83)
tab n11ba




***Short-term panel 2013

use "${data}\STP2013.dta",clear

set more off

fre n_teilnahmen


*Determine Sample for Panel 
gen panel = .
replace panel=1 if wei_w7!=-95

*Determine Sample for Panel Select 
gen panel_select = .
replace panel_select = 1 if n_teilnahmen==7



*Age
tab kpx_2290

gen alter=2013 - kpx_2290
mvdecode alter, mv (-99)
tab alter

sum alter if panel==1
sum alter if panel_select==1


*Education 
fre kpx_2320
gen bildkat=0
replace bildkat=1 if kpx_2320<=2
replace bildkat=2 if kpx_2320==3
replace bildkat=3 if kpx_2320==4 | kpx_2320==5
mvdecode bildkat, mv (0)

tab bildkat if panel==1
tab bildkat if panel_select==1

*Political Interest
fre kp1_010
mvdecode kp1_010, mv (-99)
gen polint=(5-kp1_010)/4

sum polint if panel==1
sum polint if panel_select==1

*Election Norm
fre kp1_050l
mvdecode kp1_050l, mv (-99)
gen wahlnorm=kp1_050l
replace wahlnorm=(wahlnorm-1)/4

tabstat wahlnorm if panel==1, sta (n min max mean sd)
tabstat wahlnorm if panel_select==1, sta (n min max mean sd)

*Party Identification
fre kp1_2090a

gen pid=0
replace pid=1 if kp1_2090a>=2 & kp1_2090a<=801
replace pid=. if kp1_2090a==-99
gen cdupid=0
replace cdupid=1 if kp1_2090a==2 | kp1_2090a==3
replace cdupid=. if kp1_2090a==-99
gen spdpid=0
replace spdpid=1 if kp1_2090a==4
replace spdpid=. if kp1_2090a==-99
gen fdppid=0
replace fdppid=1 if kp1_2090a==5
replace fdppid=. if kp1_2090a==-99
gen grupid=0
replace grupid=1 if kp1_2090a==6
replace grupid=. if kp1_2090a==-99
gen linpid=0
replace linpid=1 if kp1_2090a==7
replace linpid=. if kp1_2090a==-99

tabstat pid cdupid spdpid fdppid grupid linpid if panel==1, sta (n min max mean sd)
tabstat pid cdupid spdpid fdppid grupid linpid if panel_select==1, sta (n min max mean sd)

*Voter Turnout
fre kp7_180
gen wbt=1
replace wbt=-99 if kp7_180>=-99 & kp7_180<=-93
replace wbt=0 if kp7_180==2
mvdecode wbt, mv (-99)

tab wbt if panel==1
tab wbt if panel_select==1


*Election Result
fre kp7_200ba
mvdecode kp7_200ba, mv (-84/-99)

tab kp7_200ba if panel==1
tab kp7_200ba if panel_select==1

clear
